//
//  TeachingView.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/19.
//

#import "TeachingView.h"

@implementation TeachingView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{
        UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0,0, APPwidth, 120)];
        backview.backgroundColor = [UIColor whiteColor];
        backview.userInteractionEnabled = YES;
        [self addSubview:backview];
        //教学
        UIView *jiaoxueLine = [[UIView alloc]initWithFrame:CGRectMake(15, 10, 3, 15)];
        jiaoxueLine.backgroundColor = rgba(22, 120, 255, 1);
        jiaoxueLine.layer.cornerRadius = 2;
        [backview addSubview:jiaoxueLine];
        UILabel *jiaoxueLab = [[UILabel alloc]initWithFrame:CGRectMake(jiaoxueLine.frame.size.width+jiaoxueLine.frame.origin.x+5, 10, 70, 15)];
        jiaoxueLab.text = @"教学";
        jiaoxueLab.textColor = [UIColor blackColor];
        jiaoxueLab.textAlignment = 0;
        jiaoxueLab.font = [UIFont systemFontOfSize:16 weight:bold];
        [backview addSubview:jiaoxueLab];
    
        NSArray *jiaoxueArr = @[@"voice",@"light",@"dagang",@"video"];
        NSArray *jiexueLabArr = @[@"语音播报",@"灯光模拟",@"教学大纲",@"驾考视频"];
       
        for (int i = 0; i < jiaoxueArr.count; i++) {
            UIButton *  jiaoxueLaBtn = [[UIButton alloc]initWithFrame: CGRectMake(i*APPwidth/4,jiaoxueLab.height+jiaoxueLab.y + 10, APPwidth/4, 60)];
            jiaoxueLaBtn.titleLabel.font = [UIFont systemFontOfSize:14];
            jiaoxueLaBtn.titleLabel.textAlignment = 1;
            [jiaoxueLaBtn setBackgroundColor:[UIColor whiteColor]];
            [jiaoxueLaBtn setTitleColor:rgba(51, 51, 51, 1) forState:0];
            [jiaoxueLaBtn setImage:[UIImage imageNamed:jiaoxueArr[i]] forState:0];
            [jiaoxueLaBtn setTitle:jiexueLabArr[i] forState:0];
            jiaoxueLaBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 25, 15, 25);
            [jiaoxueLaBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
            jiaoxueLaBtn.titleEdgeInsets = UIEdgeInsetsMake(60, -45, 0, 0);
            [backview addSubview:jiaoxueLaBtn];
    
            if (i == 0) {
                _lightVoiceBtn = jiaoxueLaBtn;
//            }else if(i == 1){
//                _lightBtn = jiaoxueLaBtn;
//            }else if (i == 2){
//                _dagangBtn = jiaoxueLaBtn;
//            }else{
//                _videoBtn = jiaoxueLaBtn;
            }
        }
    
    
}

@end
